//
//  VisitorTableViewController.swift
//  微博
//
//  Created by qiukai on 16/4/6.
//  Copyright © 2016年 仇恺. All rights reserved.
//

import UIKit

class VisitorTableViewController: UITableViewController {

    private var userLogon = false
    var visitorView: VisitorTableView?
    
    override func loadView() {
        userLogon ? super.loadView() : setUpVisitorView()
        print("经过了－－－－－－－－－－－－")
    }
    override func viewDidLoad() {
        super.viewDidLoad()

        
    }

    private func setUpVisitorView()
    {
        visitorView = VisitorTableView()
        view = visitorView
        //界面按钮点击事件设置
        visitorView?.registerButton.addTarget(self, action: #selector(VisitorTableViewController.didClickRegisterButton), forControlEvents: UIControlEvents.TouchUpInside)
        visitorView?.loginButton.addTarget(self, action: #selector(VisitorTableViewController.didClickLoginButton), forControlEvents: .TouchUpInside)
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: #selector(VisitorTableViewController.didClickRegisterButton))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: .Plain, target: self, action: #selector(VisitorTableViewController.didClickLoginButton))
        navigationController?.navigationBar.tintColor = UIColor.orangeColor()
    }
    
}

// MARK: - 访客视图监听方法
extension VisitorTableViewController{
    func didClickRegisterButton(){
        print("点击了注册")
    }
    func didClickLoginButton(){
       let vc = QKOAuthViewController()
        let navc = UINavigationController(rootViewController: vc)
        presentViewController(navc, animated: true, completion: nil)
    }
}